<?php
class Helper extends Object
{
	static function instance($helperlName,$arguments="")
	{
		$path = $helperlName;
		$helperlName = explode(DIRECTORY_SEPARATOR,$helperlName);
		$count = count($helperlName);
		$count--;
		$helperlName[$count] = HELPER_PREFIX.$helperlName[$count];
		$className = $helperlName[$count];
		//die($className);
		$helperlName = implode(DIRECTORY_SEPARATOR,$helperlName);
		
		$path = PATH_HELPER.$helperlName.EXT;
		
		if(file_exists($path)){
			require_once($path);
			$script = '$helper =  new '.$className;
			if($arguments)
			{
				
				if(!is_array($arguments))
				{
					$script.='("'.$arguments.'")';
				}else{
					$script.='(';
					$count = count($arguments);
					$count--;
					$id=0;
					foreach($arguments as $argument)
					{
						$argument = addslashes($argument);
					
						if($id == $count)
						{
							$script .= "'".$argument."'";
							continue;
						}else{
							$id++;
							$script .="'". $argument."'".',';
						}
					}
					$script.=')';
				}
			}
			$script.=';';
			eval($script);
			return $helper;
		}
	}
}
?>